package com.abocode.aichat.client;

import java.io.UnsupportedEncodingException;
import java.util.ServiceLoader;

/***
 * java SPI ModuleServiceFactory
 */
public class ModuleServiceFactory {
    private static ServiceLoader<ModuleServiceSPIReceiver> decodeSetLoader = ServiceLoader.load(ModuleServiceSPIReceiver.class);
    public static ModuleServiceSPIReceiver getModuleService(String encodingName) throws UnsupportedEncodingException {
        for (ModuleServiceSPIReceiver decode : decodeSetLoader) {
            if (decode.availableReceiver(encodingName)) {
                return decode;
            }
        }
        throw new UnsupportedEncodingException();
    }

}
